package top.chukongxiang.monitorservice.jna;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum ErrorCode {

    NET_DVR_NOERROR(0, "没有错误"),
    NET_DVR_PASSWORD_ERROR(1, "用户名密码错误"),
    NET_DVR_NOENOUGHPRI(2, "权限不足"),
    NET_DVR_NOINIT(3, "没有初始化"),
    NET_DVR_CHANNEL_ERROR(4, "通道号错误"),
    NET_DVR_OVER_MAXLINK(5, "连接到DVR的客户端个数超过最大"),
    NET_DVR_VERSIONNOMATCH(6, "版本不匹配"),
    NET_DVR_NETWORK_FAIL_CONNECT(7, "连接服务器失败"),
    NET_DVR_NETWORK_SEND_ERROR(8, "向服务器发送失败"),
    NET_DVR_NETWORK_RECV_ERROR(9, "从服务器接收数据失败"),
    NET_DVR_NETWORK_RECV_TIMEOUT(10, "从服务器接收数据超时"),
    NET_DVR_NETWORK_ERRORDATA(11, "传送的数据有误"),

    ;
    private final int value;
    private final String label;

    public ErrorCode match(int value) {
        for (ErrorCode errorCode : values()) {
            if (value == errorCode.value) {
                return errorCode;
            }
        }
        return null;
    }

    private String matchLabel(int value) {
        ErrorCode errorCode = match(value);
        return errorCode == null ? null : errorCode.label;
    }
}
